package com.tisson.bo;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.tisson.dao.AreaDAO;
import com.tisson.pojo.Area;

public class AreaBO {

	public void create(Area pojo){
		AreaDAO dao = new AreaDAO();
		dao.save(pojo);
	}
	
	public List findAll(HttpServletRequest request){
		try{
			AreaDAO dao = new AreaDAO();
			FilterBO bo = new FilterBO();
			return bo.getAreaList(dao.findAll(), request);
		}
		catch(Exception e){
			e.printStackTrace();
			return new ArrayList();
		}
	}
	
	public void delete(Area pojo){
		try{
			AreaDAO dao = new AreaDAO();
			List<String> idList = new ArrayList();
			idList.add(pojo.getAreaId());
			dao.delete(idList);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public Area findById(String AreaId){
		try{
			AreaDAO dao = new AreaDAO();
			List<String> idList = new ArrayList();
			idList.add(AreaId);
			return (Area)dao.findById(idList).get(0);
		}
		catch(Exception e){
			e.printStackTrace();
			return new Area();
		}
	}
	
	public void update(Area area){
		try{
			AreaDAO dao = new AreaDAO();
			dao.update(area);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}
